Calling the method does not raise an exception but a notice (depending on settings).
PHPUnit just happens to turn this into an exception. The test thus breaks if PHPUnit
does not do this, which apparently happens in some cases and caused bug 41491
Change-Id: I9d14fd875c70c8b3d164c0b8a4fa2667c5769682
* @param GenericArrayObject $list
*/
public function testUnset( GenericArrayObject $list ) {
- if ( !$list->isEmpty() ) {
+ if ( $list->isEmpty() ) {
+ $this->assertTrue( true ); // We cannot test unset if there are no elements
+ }
+ else {
$offset = $list->getIterator()->key();
$count = $list->count();
$list->offsetUnset( $offset );
unset( $list[$offset] );
$this->assertEquals( $count - 1, $list->count() );
}
-
- $exception = null;
- try { $list->offsetUnset( 'sdfsedtgsrdysftu' ); } catch ( \Exception $exception ){}
- $this->assertInstanceOf( '\Exception', $exception );
}
/**